﻿using System.Diagnostics;
using System.Threading.Tasks;
using LmgCMS.Model;
using Quartz;
using static Quartz.Logging.OperationName;

namespace LmgCMS.Service
{
    /// <summary>
    /// LmgCMS.Service.SysLogJob
    /// </summary>
    public class SysLogJob : IJob
    {
        private IOpenJobService _openJob;
        private ILogger<SysLogJob> _logger;
        private ILoginInfo _auth;
        private ISysLogService _sysLog;
        public SysLogJob(IOpenJobService openJob, ILogger<SysLogJob> logger, ILoginInfo auth, ISysLogService sysLog)
        {
            _openJob = openJob;
            _logger = logger;
            _auth = auth;
            _sysLog = sysLog;
        }
        public Task Execute(IJobExecutionContext context)
        {
            var jobId = context.MergedJobDataMap.GetString(Define.JOBMAPKEY);
            var model = _openJob.Find(x => x.ID == jobId);
            //todo:这里可以加入自己的自动任务逻辑





            Debug.Print("任务调度名称：" + model.JobName);
            _openJob.RecordRun(jobId);
            return Task.Delay(1);
        }
    }
}